package com.zmn.plat.manager.dictionary;

/**
 * 是否允许
 *
 * @author xiangjunming
 * @since 2019 /08/20 14:47:16
 */
public enum YesNoEnum {

    /**
     * values
     */
    NO(1, "不允许"),
    YES(2, "允许"),
    ;

    private Integer code;
    private String name;

    YesNoEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static YesNoEnum of(Integer code) {
        if (code == null) {
            return null;
        }
        switch (code) {
            case 1:
                return NO;
            case 2:
                return YES;
            default:
                return null;
        }
    }

    public static String getName(Integer code) {
        YesNoEnum of = of(code);
        return of == null ? null : of.getName();
    }
}
